<?php include('header.php'); ?>
<aside id="side-nav" class="span3">
	<?php include 'side.php'; ?>
</aside>
<?php
	
	$con = mysql_connect("localhost", "group5", "group5");
    if(!$con)
    {
                echo "Connection failed!";
        exit;
    }
	
	mysql_select_db("group5");
	
	$userId = $_SESSION['userId'];
								
	$query = mysqlquery("SELECT DISTINCT firstName, lastName, title, workshopDescription, bldgName, bldgNum,
				roomNumber, meetingTime, meetingDay,
				workshop_sessions.workshopSessionID as workshopSessionID 
				FROM building, room, users, workshop, user_workshop, workshop_sessions
				WHERE user_workshop.workshopSessionId = workshop_sessions.workshopSessionId
				AND workshop.workshopId = workshop_sessions.workshopId
				AND room.roomId = workshop_sessions.roomId
				AND building.bldgId = room.bldgId
				AND user_workshop.userId = users.userId", $con);					
?>

<div class="span9 content-container">
        <div id="content-window" class="content">
          <h3>Sessions Report</h3>
		<form method="post">
		<table class="table table-condensed table-striped table-bordered">
			<?php 	
				if(mysql_num_rows($query) > 0){
			?>
			<tr>
				<th>Workshop Session</th>
				<th>Description</th>
				<th>Building</th>
				<th>Room Location</th>
				<th>Day</th>
				<th>Time</th>
			</tr>
			<?php
				while($row = mysql_fetch_assoc($query)){ 
			?>
			<tr>
				<td><?php echo $row['workshopSessionID'];?></td>
				<td><?php echo $row['firstName'] . " " . $row['lastName']; ?></td>
				<td><?php echo $row['title'];?></td>
				<td><?php echo $row['workshopDescription']; ?></td>
				<td><?php echo $row['bldgName'] . " " . $row['bldgNum']; ?></td>
				<td><?php echo $row['roomNumber']; ?></td>
				<td><?php echo $row['meetingDay']; ?></td>
				<td><?php echo $row['meetingTime']; ?></td>
           <?php }
				}else{ 
			?>
				<td colspan="8" style="color: red; text-align: center"><p>No users registered for any sessions.</p></td>
			<?php } ?>
		</table>
		</form>
 <?php mysql_close($con);?>
</div> <!-- end .content -->
</div> <!-- end .content-container -->
<?php include('footer.php'); ?>
